package my.edu.model.bills.sales.entity.dto;


import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import jakarta.validation.groups.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;
import my.edu.common.domain.OrderProductDetail;
import my.edu.common.enumeration.OrderType;
import my.edu.common.validate.groups.Insert;
import my.edu.common.validate.groups.Purchase;

import java.math.BigDecimal;

@EqualsAndHashCode(callSuper = true)
@Data
public class SalesDetailDTO extends OrderProductDetail {
    //private Long salesOrderId;
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class, Default.class})
    @NotNull(message = "请填入销售单价！", groups = {Insert.class})
    private BigDecimal salesPrice;
    private Long warehouseId;
    private String warehouseName;
    @Min(value = 0, message = "数字必须大于0", groups = {Insert.class, Default.class})
    private BigDecimal conversionRate;//换算率

    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class, Default.class})
    private BigDecimal lastPurchasePrice;
    private String remark;

    @Override
    public BigDecimal getCurrentPrice() {
        return getSalesPrice();
    }

    @Override
    public void setCurrentPrice(BigDecimal price) {
        setSalesPrice(price);
    }

    @Override
    public OrderType getCurrentOrderType() {
        return OrderType.SALE_PRICE;
    }
}
